package com.nativetalk.controller.app.teacher;

import com.aliyun.openservices.oss.model.ObjectMetadata;
import com.nativetalk.base.Page;
import com.nativetalk.base.RetInfo;
import com.nativetalk.bean.authentication.TdNtAuthenticationInsert;
import com.nativetalk.bean.course.teacher.TdNtTeachCourseInsert;
import com.nativetalk.bean.dict.TsNtDictDeatil;
import com.nativetalk.bean.email.EmailUtil;
import com.nativetalk.bean.member.TdNtMember;
import com.nativetalk.bean.study.feedback.TdNtStudyTeachFeedbackInset;
import com.nativetalk.bean.study.feedback.TdNtStudyTeacherTeachFeedbackInset;
import com.nativetalk.bean.teacher.*;
import com.nativetalk.bean.website.TsNtWebSiteConfIndex;
import com.nativetalk.common.Constants;
import com.nativetalk.common.ValidationMessages;
import com.nativetalk.common.oss.OssUtil;
import com.nativetalk.common.util.CommonUtil;
import com.nativetalk.common.util.JsonUtil;
import com.nativetalk.common.util.MemcachedKey;
import com.nativetalk.common.util.MemcachedUtils;
import com.nativetalk.dto.account.UpdateDeviceIdDto;
import com.nativetalk.service.authentication.insert.AuthenticationInsertService;
import com.nativetalk.service.authentication.search.AuthenticationSearchService;
import com.nativetalk.service.course.search.CourseSearchService;
import com.nativetalk.service.course.update.CourseUpdateService;
import com.nativetalk.service.study.feedback.StudyTeachFeedbackService;
import com.nativetalk.service.study.search.StudyTeachService;
import com.nativetalk.service.study.update.StudyTeachUpdateService;
import com.nativetalk.service.teacher.login.TeacherLoginService;
import com.nativetalk.service.teacher.register.TeacherRegisterService;
import com.nativetalk.service.teacher.retrieve.TeacherRetrieveService;
import com.nativetalk.service.teacher.search.TeacherSearchService;
import com.nativetalk.service.teacher.update.TeacherUpdateService;
import com.nativetalk.service.teafound.search.TeaFoundChangeSearchService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class TeacherController {
    private static Logger logger = Logger.getLogger(TeacherController.class);
    @Resource
    private TeacherRegisterService teacherRegisterService;
    @Resource
    private TeacherRetrieveService teacherRetrieveService;
    @Resource
    private TeacherLoginService teacherLoginService;
    @Resource
    private TeacherUpdateService teacherUpdateService;
    @Resource
    private TeacherSearchService teacherSearchService;
    @Resource
    private TeaFoundChangeSearchService teaFoundChangeSearchService;
    @Resource
    private StudyTeachService studyTeachService;
    @Resource
    private StudyTeachFeedbackService studyTeachFeedbackService;
    @Resource
    private CourseSearchService courseSearchService;
    @Resource
    private CourseUpdateService courseUpdateService;
    @Resource
    private AuthenticationInsertService authenticationInsertService;
    @Resource
    private StudyTeachUpdateService studyTeachUpdateService;
    @Resource
    private AuthenticationSearchService authenticationSearchService;
    @RequestMapping(value = "/app/1/teacher/sendRgEmail" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo sendRgEmail(@Valid @RequestBody EmailUtil emailUtil, BindingResult result) {
        RetInfo retInfo = new RetInfo();
        if (result.hasErrors()) {
            List<FieldError> err=result.getFieldErrors();
            FieldError fe = err.get(0);
            retInfo.setMark(ValidationMessages.getValue("MARKPARAMETERERROR"));
            retInfo.setTip(fe.getDefaultMessage());

        }else {
            try {
                //打印入参
                logger.info(Constants.prefix_in + JsonUtil.toJson(emailUtil));

                retInfo = teacherRegisterService.sendEmail(emailUtil);

                //打印出参
                logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            } catch (Exception e) {
                //记录错误日志
                retInfo = RetInfo.getServerErrorInfo();
                logger.error(e.getMessage(), e);

                //打印出参
                logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            }

        }
        return retInfo;
    }
    @RequestMapping(value = "/app/1/teacher/register" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo register(@Valid @RequestBody TdNtTeacherRegister tdNtTeacherRegister, BindingResult result,
                            @RequestHeader(value = "client_type", required = true) String client_type) {
        RetInfo retInfo = new RetInfo();
        if (result.hasErrors()) {
            List<FieldError> err=result.getFieldErrors();
            FieldError fe = err.get(0);
            retInfo.setMark(ValidationMessages.getValue("MARKPARAMETERERROR"));
            retInfo.setTip(fe.getDefaultMessage());
        }else {
            try {
                //打印入参
                logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtTeacherRegister));

                tdNtTeacherRegister.setEqu_type(client_type);
                retInfo = teacherRegisterService.register(tdNtTeacherRegister);

                //打印出参
                logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            } catch (Exception e) {
                //记录错误日志
                retInfo = RetInfo.getServerErrorInfo();
                logger.error(e.getMessage(), e);

                //打印出参
                logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            }

        }
        return retInfo;
    }
    @RequestMapping(value = "/app/1/teacher/sendRtEmail" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo sendRtEmail(@Valid @RequestBody EmailUtil emailUtil, BindingResult result) {
        RetInfo retInfo = new RetInfo();
        if (result.hasErrors()) {
            List<FieldError> err=result.getFieldErrors();
            FieldError fe = err.get(0);
            retInfo.setMark(ValidationMessages.getValue("MARKPARAMETERERROR"));
            retInfo.setTip(fe.getDefaultMessage());
        }else {
            try {
                //打印入参
                logger.info(Constants.prefix_in + JsonUtil.toJson(emailUtil));

                retInfo = teacherRetrieveService.sendEmail(emailUtil);

                //打印出参
                logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            } catch (Exception e) {
                //记录错误日志
                retInfo = RetInfo.getServerErrorInfo();
                logger.error(e.getMessage(), e);

                //打印出参
                logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            }
        }
        return retInfo;
    }
    @RequestMapping(value = "/app/1/teacher/retrieve" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo retrieve(@Valid @RequestBody TdNtTeacherRetrive tdNtTeacherRetrive, BindingResult result) {
        RetInfo retInfo = new RetInfo();
        if (result.hasErrors()) {
            List<FieldError> err=result.getFieldErrors();
            FieldError fe = err.get(0);
            retInfo.setMark(ValidationMessages.getValue("MARKPARAMETERERROR"));
            retInfo.setTip(fe.getDefaultMessage());
        }else {
            try {
                //打印入参
                logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtTeacherRetrive));

                retInfo = teacherRetrieveService.retrieve(tdNtTeacherRetrive);

                //打印出参
                logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            } catch (Exception e) {
                //记录错误日志
                retInfo = RetInfo.getServerErrorInfo();
                logger.error(e.getMessage(), e);

                //打印出参
                logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            }

        }
        return retInfo;
    }
    @RequestMapping(value = "/app/1/teacher/login" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo login(@Valid @RequestBody TdNtTeacherLogin tdNtTeacherLogin, BindingResult result,
                         @RequestHeader(value = "client_type", required = true) String client_type) {
        RetInfo retInfo = new RetInfo();
        if (result.hasErrors())   {
            List<FieldError> err=result.getFieldErrors();
            FieldError    fe = err.get(0);
            retInfo.setMark(ValidationMessages.getValue("MARKPARAMETERERROR"));
            retInfo.setTip(fe.getDefaultMessage());
        }else {
            try {
                //打印入参
                logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtTeacherLogin));

                retInfo.setMark("1");
                retInfo.setTip("We updated a new version! Check it out! ");

                //打印出参
                logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            } catch (Exception e) {
                //记录错误日志
                retInfo = RetInfo.getServerErrorInfo();
                logger.error(e.getMessage(), e);

                //打印出参
                logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            }

        }
        return retInfo;
    }

    @RequestMapping(value = "/app/1/teatoken/teacher/out" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo out(@RequestHeader(value = "token", required = true) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in);

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            retInfo = teacherLoginService.out(tdNtTeacherResult);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value = "/app/1/teatoken/teacher/updatePsd" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo updatePsd(@Valid @RequestBody TdNtTeacherPsd tdNtTeacherPsd, BindingResult result,
                       @RequestHeader(value = "token", required = true) String token) {
        RetInfo retInfo = new RetInfo();
        if (result.hasErrors()) {
            List<FieldError> err=result.getFieldErrors();
            FieldError fe = err.get(0);
            retInfo.setMark(ValidationMessages.getValue("MARKPARAMETERERROR"));
            retInfo.setTip(fe.getDefaultMessage());
        }else {
            try {
                //打印入参
                logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtTeacherPsd));

                TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
                retInfo = teacherUpdateService.updateTeacherPsd(tdNtTeacherPsd,tdNtTeacherResult);

                //打印出参
                logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            } catch (Exception e) {
                //记录错误日志
                retInfo = RetInfo.getServerErrorInfo();
                logger.error(e.getMessage(), e);

                //打印出参
                logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            }
        }
        return retInfo;
    }
    @RequestMapping(value = "/app/1/teatoken/teacher/updateName" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo updateName(@Valid @RequestBody TdNtTeacherName tdNtTeacherName, BindingResult result,
                              @RequestHeader(value = "token", required = true) String token) {
        RetInfo retInfo = new RetInfo();
        if (result.hasErrors()) {
            List<FieldError> err=result.getFieldErrors();
            FieldError fe = err.get(0);
            retInfo.setMark(ValidationMessages.getValue("MARKPARAMETERERROR"));
            retInfo.setTip(fe.getDefaultMessage());
        }else {
            try {
                //打印入参
                logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtTeacherName));

                TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
                tdNtTeacherResult.setTea_name(tdNtTeacherName.getTea_name());
                retInfo = teacherUpdateService.updateTeacher(tdNtTeacherResult);

                //打印出参
                logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            } catch (Exception e) {
                //记录错误日志
                retInfo = RetInfo.getServerErrorInfo();
                logger.error(e.getMessage(), e);

                //打印出参
                logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            }

        }
        return retInfo;
    }
    @RequestMapping(value = "/app/1/teatoken/teacher/updateSex" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo updateSex(@Valid @RequestBody TdNtTeacherSex tdNtTeacherSex, BindingResult result,
                              @RequestHeader(value = "token", required = true) String token) {
        RetInfo retInfo = new RetInfo();
        if (result.hasErrors()) {
            List<FieldError> err=result.getFieldErrors();
            FieldError fe = err.get(0);
            retInfo.setMark(ValidationMessages.getValue("MARKPARAMETERERROR"));
            retInfo.setTip(fe.getDefaultMessage());
        }else {
            try {
                //打印入参
                logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtTeacherSex));

                TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
                tdNtTeacherResult.setTea_sex(tdNtTeacherSex.getTea_sex());
                retInfo = teacherUpdateService.updateTeacher(tdNtTeacherResult);

                //打印出参
                logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            } catch (Exception e) {
                //记录错误日志
                retInfo = RetInfo.getServerErrorInfo();
                logger.error(e.getMessage(), e);

                //打印出参
                logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            }

        }
        return retInfo;
    }
    @RequestMapping(value = "/app/1/teatoken/teacher/updateBirthday" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo updateBirthday(@Valid @RequestBody TdNtTeacherBirthday tdNtTeacherBirthday, BindingResult result,
                             @RequestHeader(value = "token", required = true) String token) {
        RetInfo retInfo = new RetInfo();
        if (result.hasErrors()) {
            List<FieldError> err=result.getFieldErrors();
            FieldError fe = err.get(0);
            retInfo.setMark(ValidationMessages.getValue("MARKPARAMETERERROR"));
            retInfo.setTip(fe.getDefaultMessage());
        }else {
            try {
                //打印入参
                logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtTeacherBirthday));

                TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
                tdNtTeacherResult.setTea_birthday(tdNtTeacherBirthday.getTea_birthday());
                tdNtTeacherResult.setTea_ages(CommonUtil.getAge(new Date(tdNtTeacherBirthday.getTea_birthday().getTime())));
                retInfo = teacherUpdateService.updateTeacher(tdNtTeacherResult);

                //打印出参
                logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            } catch (Exception e) {
                //记录错误日志
                retInfo = RetInfo.getServerErrorInfo();
                logger.error(e.getMessage(), e);

                //打印出参
                logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            }

        }
        return retInfo;
    }
    @RequestMapping(value = "/app/1/teatoken/teacher/updateSynopis" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo updateSynopis(@Valid @RequestBody TdNtTeacherSynopsis tdNtTeacherSynopsis, BindingResult result,
                                  @RequestHeader(value = "token", required = true) String token) {
        RetInfo retInfo = new RetInfo();
        if (result.hasErrors()) {
            List<FieldError> err=result.getFieldErrors();
            FieldError fe = err.get(0);
            retInfo.setMark(ValidationMessages.getValue("MARKPARAMETERERROR"));
            retInfo.setTip(fe.getDefaultMessage());
        }else {
            try {
                //打印入参
                logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtTeacherSynopsis));

                TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
                tdNtTeacherResult.setTea_synopsis(tdNtTeacherSynopsis.getTea_synopsis());
                retInfo = teacherUpdateService.updateTeacher(tdNtTeacherResult);

                //打印出参
                logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            } catch (Exception e) {
                //记录错误日志
                retInfo = RetInfo.getServerErrorInfo();
                logger.error(e.getMessage(), e);

                //打印出参
                logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            }

        }
        return retInfo;
    }
    @RequestMapping(value = "/app/1/teatoken/teacher/updateSoundSynopis" ,method = {RequestMethod.GET,RequestMethod.POST} )
    @ResponseBody
    public RetInfo updateSoundSynopis(@RequestParam(value = "soundSynopis", required = true) CommonsMultipartFile commonsMultipartFile,
                                 @RequestHeader(value = "token", required = true) String token) throws IOException {
        RetInfo retInfo = new RetInfo();
        TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
        if (commonsMultipartFile != null && commonsMultipartFile.getSize() > 31457280) {
            retInfo.setMark(ValidationMessages.getValue("MARKNO"));
            retInfo.setTip("声音简介超过30M");
        }else {
            try {
                //打印入参
                logger.info(Constants.prefix_in + JsonUtil.toJson(commonsMultipartFile.getOriginalFilename()));

                ObjectMetadata objectMetadata = new ObjectMetadata();
                objectMetadata.setContentLength(commonsMultipartFile.getSize());
                String soundSynopis = Constants.FILE + "/" + Constants.FILEIMG + "/sound/teacher/" + tdNtTeacherResult.getTea_id() + "/"
                        +new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis()))+"2"+commonsMultipartFile.getOriginalFilename().substring(commonsMultipartFile.getOriginalFilename().lastIndexOf("."));
                OssUtil.uploadInputStream(commonsMultipartFile.getInputStream(), objectMetadata, soundSynopis);
                tdNtTeacherResult.setTea_sound_synopsis(soundSynopis);
                retInfo = teacherUpdateService.updateTeacher(tdNtTeacherResult);

                //打印出参
                logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            } catch (Exception e) {
                //记录错误日志
                retInfo = RetInfo.getServerErrorInfo();
                logger.error(e.getMessage(), e);

                //打印出参
                logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            }

        }
        return retInfo;
    }
    @RequestMapping(value = "/app/1/teatoken/teacher/data" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo data(@RequestHeader(value = "token", required = true) String token,
                        @RequestHeader(value = "version", required = true) int version) {
        RetInfo retInfo = new RetInfo();
        Map<String , Object> map = new HashMap<>();
        try {
            //打印入参
            logger.info(Constants.prefix_in);

            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            map.put("tea_sund_synopsis" , tdNtTeacherResult.getTea_sound_synopsis());
            map.put("tea_name" , tdNtTeacherResult.getTea_name());
            map.put("tea_email" , tdNtTeacherResult.getTea_email());
            map.put("tea_sex" , tdNtTeacherResult.getTea_sex());
            map.put("tea_birthday" , tdNtTeacherResult.getTea_birthday());
            map.put("tea_synopsis" , tdNtTeacherResult.getTea_synopsis());
            if (version >= 8) {
                Map<String, TsNtDictDeatil> tsNtDictDeatilsMap =
                        (Map<String, TsNtDictDeatil>) MemcachedUtils.get(MemcachedKey.tsNtDictDeatilsMap);
                String country = tdNtTeacherResult.getNationality() + "";
                if (tdNtTeacherResult.getNationality() == 0) {
                    country = "1";
                }
                map.put("nationality" ,
                        tsNtDictDeatilsMap.get(country).getCode_eng_name());
            }
            retInfo.setMark(ValidationMessages.getValue("MARKYES"));
            retInfo.setTip("获取个人资料成功");
            retInfo.setObj(map);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value = "/app/1/teatoken/teacher/account" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo account(@RequestHeader(value = "token", required = true) String token) {
        RetInfo retInfo = new RetInfo();
        Map<String , Object> map = new HashMap<>();
        try {
            //打印入参
            logger.info(Constants.prefix_in);

            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            map.put("tea_head_portrait" , tdNtTeacherResult.getTea_head_portrait());
            map.put("tea_name" , tdNtTeacherResult.getTea_name());
            map.put("tea_score" , tdNtTeacherResult.getTea_score());
            map.put("state" , tdNtTeacherResult.getTea_islock());
            map.put("contact",tdNtTeacherResult.getContact());
            retInfo.setMark(ValidationMessages.getValue("MARKYES"));
            retInfo.setTip("获取account成功");
            retInfo.setObj(map);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }

    }

    @RequestMapping(value = "/app/1/teatoken/teacher/balance" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo balance(@RequestHeader(value = "token", required = true) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in);

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            retInfo = teacherSearchService.findTeacherBalance(tdNtTeacherResult.getTea_id());

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }

    }

    @RequestMapping(value = "/app/1/teatoken/teacher/invitation" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo invitation(@RequestHeader(value = "token", required = true) String token) {
        RetInfo retInfo = new RetInfo();
        Map<String , Object> map = new HashMap<>();
        try {
            //打印入参
            logger.info(Constants.prefix_in);

            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            map.put("invite_code" , tdNtTeacherResult.getTea_invite_code());
            Map<String , TsNtWebSiteConfIndex> tsNtWebSiteConfIndexMap = (Map<String , TsNtWebSiteConfIndex>)MemcachedUtils.get(MemcachedKey.tsNtWebSiteConfIndexMap);
            map.put("invite_picture" , tsNtWebSiteConfIndexMap.get("4").getData_value());
            map.put("invite_synopis" , tsNtWebSiteConfIndexMap.get("5").getData_value());
            map.put("invite_url" , "http://www.baidu.com");
            map.put("invite_title" , "外教君");
            retInfo.setMark(ValidationMessages.getValue("MARKYES"));
            retInfo.setTip("获取邀请信息成功");
            retInfo.setObj(map);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value = "/app/1/teatoken/teacher/index" ,method = {RequestMethod.GET,RequestMethod.POST},consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo index(@RequestHeader(value = "token", required = true) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in);

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            retInfo = teacherSearchService.findTeacherIndex(tdNtTeacherResult.getTea_id());

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value = "/app/1/teatoken/teacher/state" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo state(@Valid @RequestBody TdNtTeacherState tdNtTeacherState  , BindingResult result,
                         @RequestHeader(value = "token", required = true) String token) {
        RetInfo retInfo = new RetInfo();
        if (result.hasErrors()) {
            List<FieldError> err=result.getFieldErrors();
            FieldError fe = err.get(0);
            retInfo.setMark(ValidationMessages.getValue("MARKPARAMETERERROR"));
            retInfo.setTip(fe.getDefaultMessage());
        }else {
//            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
//            tdNtTeacherState.setTea_id(tdNtTeacherResult.getTea_id());
//            retInfo = teacherUpdateService.updateTeacherState(tdNtTeacherState);
            retInfo.setMark("1");
            retInfo.setTip("We updated a new version! Check it out! ");
        }
        return retInfo;
    }

    @RequestMapping(value = "/app/1/teatoken/teacher/found" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json; charset=utf-8" )
    @ResponseBody
    public RetInfo found(@RequestBody Map<String,String> map,
                         @RequestHeader(value = "token", required = true) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(map));

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            retInfo = teaFoundChangeSearchService.findFoundChangeByTeaId(tdNtTeacherResult.getTea_id(),Integer.valueOf(map.get("currentPage")),10);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value="/app/1/teatoken/teacher/studyTeach" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json")
    @ResponseBody
    public RetInfo studyTeach(@RequestBody Map<String,String> map,
                              @RequestHeader(value = "token", required = true) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(map));

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            retInfo = studyTeachService.findStudyTeachTeacherPage(tdNtTeacherResult.getTea_id(),Integer.valueOf(map.get("currentPage")),10);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value="/app/1/teatoken/teacher/studyTeach/detail" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json")
    @ResponseBody
    public RetInfo detail(@RequestBody Map<String,Integer> map,
                          @RequestHeader(value = "token", required = true) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(map));

            RetInfo retInfo;
            retInfo = studyTeachService.findStudyTeachTeacherDetail(map.get("stt_id"));

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value="/app/1/teatoken/teacher/studyTeach/feedback" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json")
    @ResponseBody
    public RetInfo feedback(@Valid @RequestBody TdNtStudyTeacherTeachFeedbackInset tdNtStudyTeacherTeachFeedbackInset, BindingResult result,
                            @RequestHeader(value = "token", required = true) String token) {
        RetInfo retInfo = new RetInfo();
        if (result.hasErrors()) {
            List<FieldError> err=result.getFieldErrors();
            FieldError fe = err.get(0);
            retInfo.setMark(ValidationMessages.getValue("MARKPARAMETERERROR"));
            retInfo.setTip(fe.getDefaultMessage());
        }else {
            try {
                //打印入参
                logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtStudyTeacherTeachFeedbackInset));

                TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
                TdNtStudyTeachFeedbackInset tdNtStudyTeachFeedbackInset = new TdNtStudyTeachFeedbackInset();
                tdNtStudyTeachFeedbackInset.setUser_cate(2);
                tdNtStudyTeachFeedbackInset.setTea_id(tdNtTeacherResult.getTea_id());
                tdNtStudyTeachFeedbackInset.setStf_cate(tdNtStudyTeacherTeachFeedbackInset.getStf_cate());
                tdNtStudyTeachFeedbackInset.setStf_content(tdNtStudyTeacherTeachFeedbackInset.getStf_content());
                tdNtStudyTeachFeedbackInset.setStf_title(tdNtStudyTeacherTeachFeedbackInset.getStf_title());
                tdNtStudyTeachFeedbackInset.setStt_id(tdNtStudyTeacherTeachFeedbackInset.getStt_id());
                retInfo = studyTeachFeedbackService.inserttudyTeachFeedback(tdNtStudyTeachFeedbackInset);

                //打印出参
                logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            } catch (Exception e) {
                //记录错误日志
                retInfo = RetInfo.getServerErrorInfo();
                logger.error(e.getMessage(), e);

                //打印出参
                logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
                return retInfo;
            }
        }
        return retInfo;
    }

    @RequestMapping(value="/app/1/teatoken/teacher/course" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json")
    @ResponseBody
    public RetInfo course(@RequestHeader(value = "token", required = true) String token,
                          @RequestHeader(value = "version", required = true) Integer version) {
        try {
            //打印入参
            logger.info(Constants.prefix_in);

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            retInfo = courseSearchService.findCourse(tdNtTeacherResult.getTea_id(),version);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value = "/app/11/teatoken/teacher/course/find", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo findCourseByCategory(@RequestBody Map<String, Integer> map,
                                        @RequestHeader(value = "token", required = true) String token,
                                        @RequestHeader(value = "version", required = true) Integer version) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(map));

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            Integer categoryId = map.get("categoryId");
            retInfo = courseSearchService.findCourseByCategoryId(tdNtTeacherResult.getTea_id(), version, categoryId);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value = "/app/11/teatoken/teacher/category/find", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo findCategory(@RequestHeader(value = "token", required = true) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in);

            RetInfo retInfo;
            retInfo = courseSearchService.findCategory();

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value="/app/1/teatoken/teacher/course/update" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json")
    @ResponseBody
    public RetInfo update(@RequestBody Map<String,Integer> map,
                          @RequestHeader(value = "token", required = true) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(map));

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            retInfo = courseUpdateService.openCourse(map.get("cate_id"), tdNtTeacherResult.getTea_id(),map.get("tc_state"));

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value="/app/1/teatoken/teacher/course/add" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json")
    @ResponseBody
    public RetInfo add( @RequestBody Map<String,Integer> map,
                       @RequestHeader(value = "token", required = true) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(map));

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            TdNtTeachCourseInsert tdNtTeachCourseInsert = new TdNtTeachCourseInsert();
            tdNtTeachCourseInsert.setCou_id(map.get("cate_id"));
            tdNtTeachCourseInsert.setTea_id(tdNtTeacherResult.getTea_id());
            retInfo = courseUpdateService.addTeachCoures(tdNtTeachCourseInsert);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value="/app/1/teatoken/teacher/head" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json")
    @ResponseBody
    public RetInfo head() {
        RetInfo retInfo = new RetInfo();
        Map<String , Object> map = new HashMap<>();
        try {
            //打印入参
            logger.info(Constants.prefix_in);

            Map<String , TsNtWebSiteConfIndex> tsNtWebSiteConfIndexMap = (Map<String , TsNtWebSiteConfIndex>)MemcachedUtils.get(MemcachedKey.tsNtWebSiteConfIndexMap);
            map.put("head_portrait" , tsNtWebSiteConfIndexMap.get("8").getData_value());
            map.put("head_synopis" , tsNtWebSiteConfIndexMap.get("7").getData_value());

            retInfo.setMark(ValidationMessages.getValue("MARKYES"));
            retInfo.setTip("获取成功");
            retInfo.setObj(map);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value="/app/1/teatoken/teacher/apply" ,method = {RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public RetInfo apply(@Valid @ModelAttribute TdNtAuthenticationInsert tdNtAuthenticationInsert, BindingResult result,
                         @RequestHeader(value = "token", required = true) String token) throws  IOException{
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtAuthenticationInsert));

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            tdNtAuthenticationInsert.setTea_id(tdNtTeacherResult.getTea_id());
            retInfo = authenticationInsertService.insertAuthentication(tdNtAuthenticationInsert);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value="/app/1/teatoken/teacher/eceivingOrders" ,method = {RequestMethod.GET,RequestMethod.POST},consumes = "application/json")
    @ResponseBody
    public RetInfo eceivingOrders(@Valid @RequestBody Map<String,Integer> map,
                         @RequestHeader(value = "token", required = true) String token,
                                  @RequestHeader(value = "version", required = true) Integer version) throws  IOException{
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(map));

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            retInfo = studyTeachUpdateService.eceivingOrders(map.get("stt_id"),tdNtTeacherResult.getTea_id(),2,version);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value="/app/3/teatoken/teacher/eceivingOrders" ,method = {RequestMethod.GET,RequestMethod.POST},consumes = "application/json")
    @ResponseBody
    public RetInfo eceivingOrdersThree(@Valid @RequestBody Map<String,Integer> map,
                                  @RequestHeader(value = "token", required = true) String token,
                                  @RequestHeader(value = "version", required = true) Integer version) throws  IOException{
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(map));

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            retInfo = studyTeachUpdateService.eceivingOrdersThree(map.get("stt_id"),tdNtTeacherResult.getTea_id(),2,version);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value="/app/1/teatoken/teacher/apply/history" ,method = {RequestMethod.GET,RequestMethod.POST},consumes = "application/json")
    @ResponseBody
    public RetInfo history(@RequestHeader(value = "token", required = true) String token) throws  IOException{
        try {
            //打印入参
            logger.info(Constants.prefix_in);

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            retInfo = authenticationSearchService.findAuthentication(tdNtTeacherResult.getTea_id());

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value="/app/1/teatoken/teacher/studyTeach/end" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json")
    @ResponseBody
    public RetInfo end(@RequestBody Map<String,Integer> map,
                       @RequestHeader(value = "token", required = true) String token,
                       @RequestHeader(value = "version", required = true) String version) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(map));

            RetInfo retInfo;
            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            retInfo = studyTeachUpdateService.end(map.get("stt_id"),version);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value="/app/1/teatoken/teacher/minute" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json")
    @ResponseBody
    public RetInfo minute() {
        try {
            //打印入参
            logger.info(Constants.prefix_in);

            RetInfo retInfo = new RetInfo();
            Map<String , TsNtWebSiteConfIndex> tsNtWebSiteConfIndexMap = (Map<String , TsNtWebSiteConfIndex>)MemcachedUtils.get(MemcachedKey.tsNtWebSiteConfIndexMap);
            BigDecimal sutdy_amount = new BigDecimal(tsNtWebSiteConfIndexMap.get("25").getData_value());
            retInfo.setMark("0");
            retInfo.setObj(sutdy_amount);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value = "/app/3/teachers/list", method = {RequestMethod.GET, RequestMethod.POST},consumes = "application/json")
    @ResponseBody
    public RetInfo list(@RequestBody Page page,
                        @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            retInfo = teacherSearchService.findTeacherList(page,tdNtMember);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value = "/app/3/token/teachers/attentionlist", method = {RequestMethod.GET, RequestMethod.POST},consumes = "application/json")
    @ResponseBody
    public RetInfo attentionlist(@RequestBody Page page,
                        @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            retInfo = teacherSearchService.findAttentionlist(page,tdNtMember);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }


    @RequestMapping(value="/app/3/teachers/listCommentInfo" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json")
    @ResponseBody
    public RetInfo listCommentInfo(@RequestBody Page page,
                                   @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            retInfo = teacherSearchService.findlistCommentInfo(page);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }


    @RequestMapping(value = "/app/3/teachers/funslist", method = {RequestMethod.GET, RequestMethod.POST},consumes = "application/json")
    @ResponseBody
    public RetInfo funslist(@RequestBody Page page) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(page));

            RetInfo retInfo;
            retInfo = teacherSearchService.findfunslist(page);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

    @RequestMapping(value = "/app/11/teatoken/teacher/deviceid/update", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json; charset=utf-8")
    @ResponseBody
    public RetInfo updateEquClientId(@RequestBody UpdateDeviceIdDto request,
                                     @RequestHeader(value = "token", required = false) String token,
                                     @RequestHeader(value = "client_type", required = true) String client_type) {
        RetInfo retInfo;
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(request));

            TdNtTeacherResult tdNtTeacherResult = (TdNtTeacherResult) MemcachedUtils.get(token);
            retInfo = teacherLoginService.updateEquClientId(tdNtTeacherResult.getTea_id(), request.getEqu_client_id(), client_type);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

}